﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>Click - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The Click function clicks a mouse button at the specified coordinates. It can also hold down a mouse button, turn the mouse wheel, or move the mouse." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>Click</h1>

<p>Clicks a mouse button at the specified coordinates. It can also hold down a mouse button, turn the mouse wheel, or move the mouse.</p>
<p>Here are examples of common usages (all commas are optional):</p>
<table class="info">
  <tr>
    <td style="width: 110px">Click (by itself)</td>
    <td>Clicks the left mouse button once at the mouse cursor's current position.</td>
  </tr>
  <tr>
    <td>Click "44 55"</td>
    <td>Clicks the left mouse button once at coordinates 44, 55 (based on <a href="CoordMode.htm">CoordMode</a>).</td>
  </tr>
  <tr>
    <td>Click "right 44 55"</td>
    <td>Same as above but clicks the right mouse button.</td>
  </tr>
  <tr>
    <td>Click 2</td>
    <td>Clicks the left mouse button twice at the cursor's current position (i.e. double-click).</td>
  </tr>
  <tr>
    <td>Click "down"</td>
    <td>Presses the left mouse button down and holds it.</td>
  </tr>
  <tr>
    <td>Click "up right"</td>
    <td>Releases the right mouse button.</td>
  </tr>
  <tr>
    <td>Click x, y</td>
    <td>Variables can be seperated via commas without using quotes.</td>
  </tr>
</table>
<p>Zero or more of the following items can follow the word <em>Click</em>. Separate each item from the next with at least one space, tab, and/or comma. The items can appear in any order except <em>ClickCount</em>, which must occur somewhere to the right of the coordinates (if coordinates are present).</p>
<p><strong>X, Y</strong>: The x/y coordinates to which the mouse cursor is moved prior to clicking. Coordinates are relative to the active window unless <a href="CoordMode.htm">CoordMode</a> was used to change that. If omitted, the cursor's current position is used.</p>
<p><strong>Button Name:</strong> Left (default), Right, Middle (or just the first letter of each of these); or the fourth or fifth mouse button (X1 or X2). </p>
  <p class="note"><strong>Note</strong>: Unlike <a href="MouseClick.htm">MouseClick</a>, the left and right buttons behave consistently across all systems, even if the user has swapped the buttons via the system's control panel.</p>
<p><strong>Mouse Wheel</strong>: Specify WheelUp or WU to turn the wheel upward (away from you); specify WheelDown or WD to turn the wheel downward (toward you). WheelLeft (or WL) or WheelRight (or WR) may also be specified. For <em>ClickCount</em> (below), specify the number of notches to turn the wheel. However, some applications do not obey a <em>ClickCount</em> higher than 1 for the mouse wheel. For them, use a <a href="Loop.htm">Loop</a> such as the following:</p>
<pre>Loop 5
    Click "WheelUp"</pre>
<p><strong>ClickCount</strong>: The number of times to click the mouse (examples: <code>Click 2</code>, <code>Click "100 200 2"</code>). If omitted, the button is clicked once. If coordinates are specified, <em>ClickCount</em> must appear after them. Specify zero (0) to move the mouse without clicking (例如: <code>Click "100 200 0"</code>).</p>
<p><strong>Down</strong> or <strong>Up:</strong> These words are normally omitted, in which case each click consists of a down-event followed by an up-event. Otherwise, specify <em>Down</em> (or the letter <em>D</em>) to press the mouse button down without releasing it. Later, use the word <em>Up</em> (or the letter <em>U</em>) to release the mouse button.</p>
<p><strong>Relative:</strong> The word <em>Rel</em> or <em>Relative</em> treats the specified X and Y coordinates as offsets from the current mouse position. In other words, the cursor will be moved from its current position by X pixels to the right (left if negative) and Y pixels down (up if negative).</p>
<h2 id="Remarks">备注</h2>
<p><em>Click</em> is generally preferred over <a href="MouseClick.htm">MouseClick</a> because it automatically compensates if the user has swapped the left and right mouse buttons via the system's control panel.</p>
<p><em>Click</em> uses the sending method set by <a href="SendMode.htm">SendMode</a>. To override this mode for a particular click, use a specific Send function as in this example: <code><a href="Send.htm#Click">SendEvent "{Click, 100, 200}"</a></code>.</p>
<p>To perform a shift-click or control-click, <a href="Send.htm#Click">clicking via Send</a> is generally easiest. 例如:</p>
<pre>Send "+{Click 100, 200}"  <em>; Shift+LeftClick</em>
Send "^{Click 100, 200, right}"  <em>; Control+RightClick</em></pre>
<p>Unlike <a href="Send.htm">Send</a>, <em>Click</em> does not automatically release the modifier keys (<kbd>Control</kbd>, <kbd>Alt</kbd>, <kbd>Shift</kbd>, and <kbd>Win</kbd>). 例如, if <kbd>Control</kbd> is currently down, <em>Click</em> would produce a control-click but <code>Send "{Click}"</code> would produce a normal click.</p>
<p>The <a href="SendMode.htm">SendPlay mode</a> is able to successfully generate mouse events in a broader variety of games than the other modes. In addition, some applications and games may have trouble tracking the mouse if it moves too quickly, in which case <a href="SetDefaultMouseSpeed.htm">SetDefaultMouseSpeed</a> can be used to reduce the speed (but only in <a href="SendMode.htm">SendEvent mode</a>).</p>
<p>The <a href="BlockInput.htm">BlockInput</a> function can be used to prevent any physical mouse activity by the user from disrupting the simulated mouse events produced by the mouse functions. However, this is generally not needed for the <a href="SendMode.htm">SendInput</a> and <a href="SendMode.htm">SendPlay</a> modes because they automatically postpone the user's physical mouse activity until afterward.</p>
<p>There is an automatic delay after every click-down and click-up of the mouse (except for <a href="SendMode.htm">SendInput mode</a> and for turning the mouse wheel). Use <a href="SetMouseDelay.htm">SetMouseDelay</a> to change the length of the delay.</p>
<h2 id="Related">相关</h2>
<p><a href="Send.htm#Click">Send "{Click}"</a>, <a href="SendMode.htm">SendMode</a>, <a href="CoordMode.htm">CoordMode</a>, <a href="SetDefaultMouseSpeed.htm">SetDefaultMouseSpeed</a>, <a href="SetMouseDelay.htm">SetMouseDelay</a>, <a href="MouseClick.htm">MouseClick</a>, <a href="MouseClickDrag.htm">MouseClickDrag</a>, <a href="MouseMove.htm">MouseMove</a>, <a href="ControlClick.htm">ControlClick</a>, <a href="BlockInput.htm">BlockInput</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>Click  <em>; 在鼠标光标的当前位置点击鼠标左键.</em>
Click "100 200"  <em>; 在指定坐标处点击鼠标左键.</em>
Click "100 200 0"  <em>; 移动而不点击鼠标.</em>
Click "100 200 right"  <em>; 点击鼠标右键.</em>
Click 2  <em>; 执行双击.</em>
Click "down"  <em>; 按下鼠标左键不放.</em>
Click "up right"  <em>; 释放鼠标右键.</em></pre>
</div>

</body>
</html>